<extend name="Base:common" />                                                                                                
<block name="body">
<link rel="stylesheet" type="text/css" href="__CSS__/go/MyCart.css"/>

<form id="form_paysubmit" action="{:U('Home/Yungo/paysubmit')}" method="post">
<div class="shop_payment">
	<ul class="payment">
		<li class="first_step">第一步：提交订单</li>
		<li class="arrow_1"></li>
		<li class="secend_step orange_Tech">第二步：在线支付</li>
		<li class="arrow_3"></li>
		<li class="third_step">第三步：支付成功 等待揭晓</li>
		<li class="arrow_2"></li>
		<li class="fourth_step">第四步：揭晓获得者</li>
		<!-- <li class="arrow_2"></li>
		<li class="fifth_step">第五步：晒单奖励</li> -->
	</ul>
	<div class="payment_Con">
		<ul class="order_list">
			<li class="top">
				<span class="name">商品名称</span>
				<span class="moneys">价值</span>
				<span class="money">云购价</span>
				<span class="num">云购人次</span>
				<span class="num">参与期数</span>
				<span class="all">小计</span>
			</li>     
			<volist name="cartList" id="vo">          
			<li class="end">
				<span class="name">
               		<a class="blue" href="{:U('Home/Yungo/index',array('to'=>4,'gid'=>$vo['id']))}">{$vo['title']}</a>
                </span>
				<span class="moneys">{$vo['money']}</span>
				<span class="money"><span class="color">￥<b>{$vo['yunjiage']}</b></span></span>
				<span class="num orange Fb">{$vo['num']}</span>
				<span class="num orange Fb">{$vo['qishu']}</span>
				<span class="all">{$vo['num']}</span>
			</li>
			</volist>
			<li class="payment_Total">
				<div class="payment_List_Lc"><a href="{:U('Home/Yungo/Index',array('to'=>1))}" class="form_ReturnBut">返回购物车修改订单</a></div>
				<p class="payment_List_Rc">商品合计：<span class="orange F20">{$MoneyCount}</span> 元</p>
			</li>
			<input type="hidden" id="userMoney" value="{$userMoney}">
			<input type="hidden" id="MoneyCount" value="{$MoneyCount}">
            <!-- 余额支付 start-->
			<li class="point_in" id="liPayByBalance">
				<div class="payment_List_Lc">					
					<input type="checkbox" name="moneycheckbox" id="MoneyCheckbox" class="input_choice"/>使用账户余额支付，账户余额：
					<span class="green F18">{$userMoney}</span>元
				</div>
				<p style="" class="pay_Value" id="pBalanceTip">
				<span>◆</span><em>◆</em>账户余额支付更快捷，
				<a class="blue" target="_blank" href="{:U('Home/UsersAccount/queryYue')}">立即充值</a></p>
				<p class="payment_List_Rc">余额支付：<span id="pay_money" class="orange F20">{$MoneyCount}</span> 元</p>
			</li>
            <!-- 余额支付 end--> 
		
			<li id="liPayByOther" class="point_in point_bank" style="display:list-item;">
				<div class="payment_List_Lc gary01 Fb">您的账户余额不足，请选择以下方式完成支付</div>
				<p class="payment_List_Rc">网银支付：<span id="pay_bankmoney" class="orange F20">0.00</span> 元</p>
			</li>
			
            
		</ul>
	</div>
    
	<div class="pay_bankC" id="divBankList" style="display:block;">
		<div class="bank_arrow"></div>
				<h3 class="bor">支付平台支付（推荐）：</h3>
		<ul class="click_img">
        	<li>
            <input checked="checked" type="radio" value="4" name="account" id="Tenpay">
            <img style="border:1px solid #eee; padding:1px" height="35px" width="120px" src="/Tpl/Admin/img/payment/alipay.jpg">
            </li>   
			<li>
            <input checked="checked" type="radio" value="8" name="account" id="Tenpay">
            <img style="border:1px solid #eee; padding:1px" height="35px" width="120px" src="/Tpl/Admin/img/payment/weixin.jpg">
            </li>   
		</ul>
	</div>
    <div class="payment_but" style="margin:15px 0 0 0;">
			<input type="hidden" name="submitcode" value="57b56fcfcff60">
			<input id="btnSubmit" class="shop_pay_but" type="submit" name="submit" value="确认支付">
	</div>
</form>
<div class="fast" id="fast">
        <h3>
            <span>以下商品即将揭晓，快云购吧！</span></h3>
            	<volist name="rightNowGoods" id="vo">
        		<div class="fast_list">
                    <h4>
                        <a href="{:U('Home/Yungo/index',array('to'=>4,'gid'=>$vo['id']))}" title="{$vo.title}">
                            <img src="__ROOT__/{$vo.thumb}" alt="{$vo.title}"></a></h4>
                    <ul>
                        <li class="title"><a href="{:U('Home/Yungo/index',array('to'=>4,'gid'=>$vo['id']))}" title="{$vo.title}">{$vo.title}</a></li>
                        <li>价值：￥<span>{$vo.money}</span></li>
                        <li>需要 <span style="color: #0082f0">{$vo.zongrenshu}</span> 人次参与</li>
                        <li>已参与 <span style="color: #ff0000; font-size: 16px; family: arial">{$vo.canyurenshu}</span> 人次</li>
                        <li class="buy"><a id="btnAdd2Cart" href="#" class="go_cart gotoCart" target="blank">去看看</a></li>
                    </ul>
                </div>
                </volist>                        
</div>


<p>
  <!--payment_Con end-->
  <script>
$(function(){
	var userMoney = parseFloat($('#userMoney').val());
	var MoneyCount = parseFloat($('#MoneyCount').val());
	var info={'money':userMoney,'MoenyCount':MoneyCount,"shoplen":3};
	if(info['money'] >= info['MoenyCount']){
		$("#divBankList").hide();
		$("#liPayByOther").hide();
		$("#MoneyCheckbox").attr("checked",true);
		$("#MoneyCheckbox").attr("disabled",true);
		$("#pay_money").text(info['MoenyCount']+'.00');
	}
	
	if(info['money']==0){
			$("#liPayByBalance").addClass("point_gray");
			$("#MoneyCheckbox").attr("disabled",true);
	}
	/*
	if(info['money'] < info['MoenyCount']){		
		$("#MoneyCheckbox").attr("checked",true);
		$("#pay_money").text(info['money']+'.00');
		$("#pay_bankmoney").text(info['MoenyCount']-info['money']+'.00');
		$("#MoneyCheckbox").click(function(){
			if(this.checked){
				$("#pay_money").text(info['money']+'.00');
				$("#pay_bankmoney").text(info['MoenyCount']-info['money']+'.00');
			}else{
				$("#pay_money").text('0.00');
				$("#pay_bankmoney").text(info['MoenyCount']+'.00');	
			} 
		});
	}
	*/
	if(info['money'] < info['MoenyCount']){		
		$("#liPayByBalance").addClass("point_gray");
		$("#MoneyCheckbox").attr("disabled",true);
		$("#pay_money").text('0.00');
		$("#pay_bankmoney").text(info['MoenyCount']+'.00');
		$("#MoneyCheckbox").click(function(){
			if(this.checked){
				$("#pay_money").text(info['money']+'.00');
				$("#pay_bankmoney").text(info['MoenyCount']-info['money']+'.00');
			}else{
				$("#pay_money").text('0.00');
				$("#pay_bankmoney").text(info['MoenyCount']+'.00');	
			} 
		});
	}
	
	
	$("#submit_ok").click(function(){	
		if(!this.cc){
			this.cc = 1;		
			return true;
		}else{		
			return false;
		}		
		return false;
	});
	
	$("#shop_score_num").blur(function(){
			var fufen = parseInt($(this).val());
			var money = parseInt($(this).attr("money"));
			$(this).val(Math.floor(fufen/money)*money);			
	});
	

	//$("input[@type=radio][@checked]").val();
	$(".click_img li>img").click(function(){			
			$(this).prev().attr("checked",'checked');
	});

    var cki = true;
	$('#form_paysubmit').submit(function(){
		$('#btnSubmit').css({'background':'#999999'});
		if(cki == false) return false;
		cki = false;
		$(this).ajaxSubmit({
			type : 'POST',
			url : '/Index.php/Go/Payment/pay',
			data:{
				channel : 'wx_pub',
				amount : '',
				code : '<?php echo $openid;?>'
			},success:function(responseText){
				if(typeof responseText == 'object'){
					if(responseText['status'] == '2'){
						window.location.href="<?php echo $gourl;?>";
						return;
					}
					cki = true;
					alert(responseText['msg']);
				}else if(typeof responseText == 'string'){
					var obj = $.parseJSON(responseText);
		            pingpp.createPayment(responseText, function(result, err) {
		               if(result == 'success'){
							window.location.href="<?php echo $gourl;?>";
					   		return;
					   }else if(result == 'cancel'){
						   $('#btnSubmit').css({'background':'#ff1b1b'});
					   		alert('取消支付');
							cki = true;
					   }else{
						   $('#btnSubmit').css({'background':'#ff1b1b'});
					   		alert('支付失败');
							cki = true;
					   }
					   $.post('<?php echo U('Cart/os');?>',{i:obj['id']},function(s){});
		            });
				}
			}
		});
		return false;
	});
	
});
      </script>
</block>

